﻿using MediatR;
using T.ApprovalRecord;
using T.Personnel.Read.API.Application.Command.ApprovalCommand;
using T.Personnel.Repository.Interface;

namespace T.Personnel.Read.API.Application.CommandHandler.ApprovalHandler
{
    public class GetApprovalHandler : IRequestHandler<GetApprovalCommand, List<ApprovalRecordd>>
    {
        private readonly IApprovalRepository approvalRepository;

        public GetApprovalHandler(IApprovalRepository approvalRepository)
        {
            this.approvalRepository = approvalRepository;
        }

        public async Task<List<ApprovalRecordd>> Handle(GetApprovalCommand request, CancellationToken cancellationToken)
        {
            var gather = await approvalRepository.GetApprovalAsync(request.Id);
            return gather;
        }
    }
}
